package com.foreknow.demo10;

import com.foreknow.demo9.Student;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 从控制台录入3次学生的信息，将3个学生的信息写到一个文件中（student.txt）,
 * 之后要对文件进行读取并输出这些学生的信息
 *
 * 1.创建3个类    学生类   功能类     测试类
 * 2.功能类的方法     定义两个方法对文件的操作：读操作和写操作
 * 3.测试类中调用功能类中的方法实现功能
 *
 *  10001 fender neu 121212
 *  10002 gibson fore 232
 *  10003 tom    fore 29301
 *
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        Student s1 = new Student(10001,"fender","neu","183918");
        Student s2 = new Student(10002,"gibson","fore","11231");
        Student s3 = new Student(10003,"tom","fore","1131");
        List<Student> list = new ArrayList<>();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        IODemo ioDemo = new IODemo();
        ioDemo.WriteFile(list);
        List<Student> list1 = ioDemo.ReadFile("student.txt");
        for (Student s:list1){
            System.out.println(s.getSid()+"--"+s.getName()+"--"+s.getSchool()+"--"+s.getPhone());
        }

    }
}
